// register definitions

#define W 0
#define F 1
#BYTE T0CON         =0XFD5
#BYTE TMR0H         =0XFD6
#BYTE TMR0L         =0XFD8
// register files
#byte INDF          =0x00
#byte TMR0          =0x01
#byte PCL           =0x02
#byte STATUS        =0x03
#byte FSR           =0x04
#byte PORTA         =0xF80
#byte PORTB         =0xF81
#byte PORTC         =0xF82
#byte PORTD         =0xF83
#byte PORTE         =0xF84

#byte EEDATA        =0x10C
#byte EEADR         =0x10D
#byte EEDATH        =0x10E
#byte EEADRH         =0x10F
#byte ADCON0 	 =0x1F
#byte ADCON1 	 =0x9F
#byte RCON =0xFD0
#byte ADRESH 	 =0x9F
#byte ADSESL 	 =0x9F

#byte PCLATH        =0x0a
#byte INTCON        =0x0b
#byte PIR1 	=0xF9E
#byte PIR2 	=0x0d
#byte PIE1 	=0x8c
#byte PIE2 	=0x8d

#byte OPTION_REG    =0x81
#byte TRISA         =0xF92 //OK
#byte TRISB         =0xF93
#byte TRISC         =0xF94
#byte TRISD         =0xF95
#byte TRISE         =0xF96

#byte EECON1        =0x18C
#byte EECON2        =0x18D

//DINH NGHIA BIT
#bit RA5	=0xF80.5
#bit RA4	=0xF80.4
#bit RA3	=0xF80.3
#bit RA2	=0xF80.2
#bit RA1	=0xF80.1
#bit RA0	=0xF80.0

#bit RB7	=0xf81.7
#bit RB6	=0xf81.6
#bit RB5	=0xf81.5
#bit RB4	=0xf81.4
#bit RB3	=0xf81.3
#bit RB2	=0xf81.2
#bit RB1	=0xf81.1
#bit RB0	=0xf81.0

#bit RC7	=0xF82.7
#bit RC6	=0xF82.6
#bit RC5	=0xF82.5
#bit RC4	=0xF82.4
#bit RC3	=0xF82.3
#bit RC2	=0xF82.2
#bit RC1	=0xF82.1
#bit RC0	=0xF82.0

#bit RD7	=0xF83.7
#bit RD6	=0xF83.6
#bit RD5	=0xF83.5
#bit RD4	=0xF83.4
#bit RD3	=0xF83.3
#bit RD2	=0xF83.2
#bit RD1	=0xF83.1
#bit RD0	=0xF83.0

#bit RE2	=0xF84.2
#bit RE1	=0xF84.1
#bit RE0	=0xF84.0
//////////////
#bit TC1 = 0xFCD.1  // tc1 =1 : dem su kien, tc1 = 0 : timer
#bit T1on = 0xFCD.0 // on off timer1
#BIT T0_ON = 0XFD5.0
#BIT TC0 = 0XFD5.5  // 0: TIMER,1:COUNTER
#BIT TMR0_PSA = 0XFD5.3  // 0 : USE PRESCALER, 1 : NOT USE PRESCALER
#bit T3on = 0xFB1.0
#BIT TMR3IF = 0XFA1.1
/////////////////////////
#bit TRISA5	=0xF92.5
#bit TRISA4	=0xF92.4
#bit TRISA3	=0xF92.3
#bit TRISA2	=0xF92.2
#bit TRISA1	=0xF92.1
#bit TRISA0	=0xF92.0

#bit TRISB7	=0xF93.7
#bit TRISB6	=0xF93.6
#bit TRISB5	=0xF93.5
#bit TRISB4	=0xF93.4
#bit TRISB3	=0xF93.3
#bit TRISB2	=0xF93.2
#bit TRISB1	=0xF93.1
#bit TRISB0	=0xF93.0

#bit TRISC7	=0xF94.7
#bit TRISC6	=0xF94.6
#bit TRISC5	=0xF94.5
#bit TRISC4	=0xF94.4
#bit TRISC3	=0xF94.3
#bit TRISC2	=0xF94.2
#bit TRISC1	=0xF94.1
#bit TRISC0	=0xF94.0

#bit TRISD7	=0xF95.7
#bit TRISD6	=0xF95.6
#bit TRISD5	=0xF95.5
#bit TRISD4	=0xF95.4
#bit TRISD3	=0xF95.3
#bit TRISD2	=0xF95.2
#bit TRISD1	=0xF95.1
#bit TRISD0	=0xF95.0

#bit TRISE2	=0xF96.2
#bit TRISE1	=0xF96.1
#bit TRISE0	=0xF96.0
////////////
#BYTE INTCON = 0XFF2
// INTCON Bits for C
#bit gie 	= 0xFF2.7
#bit peie = 0XFF2.6
#bit tmr0ie = 0XFF2.5
#bit int0ie = 0XFF2.4
#bit rbie	= 0XFF2.3
#bit tmr0if = 0XFF2.2
#bit int0if = 0XFF2.1
#bit rbif   = 0XFF2.0

// PIR1 for C           //OK
#bit pspif  = 0xF9E.7
#bit adif    = 0xF9E.6
#bit rcif    = 0xF9E.5
#bit txif    = 0xF9E.4
#bit sspif    = 0xF9E.3
#bit ccp1if    = 0xF9E.2
#bit tmr2if    = 0xF9E.1
#bit tmr1if    = 0xF9E.0

//PIR2 for C
#bit cmif    = 0x0d.6
#bit eeif    = 0x0d.4
#bit bclif  = 0x0d.3
#bit ccp2if    = 0x0d.0

// PIE1 for C
#bit adie    = 0x8c.6
#bit rcie    = 0x8c.5
#bit txie    = 0x8c.4
#bit sspie    = 0x8c.3
#bit ccp1ie    = 0x8c.2
#bit tmr2ie    = 0x8c.1
#bit tmr1ie    = 0x8c.0

//PIE2 for C
#bit osfie    = 0x8d.7
#bit cmie    = 0x8d.6
#bit eeie	= 0x8d.4

// OPTION Bits
#bit not_rbpu	= 0x81.7
#bit intedg     = 0x81.6
#bit t0cs       = 0x81.5
#bit t0se       = 0x81.4
#bit psa        = 0x81.3
#bit ps2        = 0x81.2
#bit ps1        = 0x81.1
#bit ps0        = 0x81.0

// EECON1 Bits
#bit eepgd	= 0x18c.7
#bit free   	= 0x18C.4
#bit wrerr  	= 0x18C.3
#bit wren    	= 0x18C.2
#bit wr      	= 0x18C.1
#bit rd      	= 0x18C.0

//ADCON0
#bit CHS0 	=0x1F.3
#bit CHS1 	=0x1F.4
#bit CHS2 	=0x1F.5
